#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    int n, prev = 0, ans = 1;; cin >> n;
    vector<int> arr(n); for(auto& e : arr) cin >> e;
    unordered_map<int, int> hash;
    for(int i = 0; i < n; ++i)
    {
        hash[arr[i]]++;
        while(hash[arr[i]] > 1)
        {
            hash[arr[prev]]--;
            prev++;
        }
        ans = max(ans, i - prev + 1);
    }
    cout << ans;
    return 0;
}